import { createRouter, createWebHistory, type RouteRecordRaw  } from 'vue-router'
import PhoneLogin from '../views/login/login.vue'
import PasswordLogin from '../views/login/passlogin.vue'
import Main from '../views/main/main.vue'
import Danger from '../views/main/Danger.vue'
import StudentManage from '../views/student/StudentManage.vue'
import AttendanceManage from '../views/studentkaoqin/AttendanceManage.vue'
import AbsenceStatistics from '../views/studentkaoqin/AbsenceStatistics.vue'
import LeaveManage from '../views/studentkaoqin/LeaveManage.vue'
import HistoryAttendance from '../views/studentkaoqin/HistoryAttendance.vue'
import LeaveSchoolManage from '../views/studentkaoqin/LeaveSchoolManage.vue'
import AttendanceSetting from '../views/studentkaoqin/AttendanceSetting.vue'
import TeacherAttendanceManage from '../views/teacherkaoqin/TeacherAttendanceManage.vue'
import TeacherLeaveApproval from '../views/teacherkaoqin/TeacherLeaveApproval.vue'
import TeacherAttendanceStats from '../views/teacherkaoqin/TeacherAttendanceStats.vue'
import TeacherAttendanceSettings from '../views/teacherkaoqin/TeacherAttendanceSettings.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'phoneLogin',
      component: PhoneLogin,
    },
    {
      path: '/passlogin',
      name: 'passwordLogin',
      component: PasswordLogin,
    },
    {
      path: '/main',
      name: 'main',
      component: Main,
      children: [
        { path: 'danger', name: 'danger', component: Danger },
        { path: 'student', name: 'student', component: StudentManage },

        { path: 'teacher', name: 'teacher', component: () => import('./../views/main/Teacher/index.vue') },
        { path: 'teacher/add', name: 'teacher-add', component: () => import('./../views/main/Teacher/Add.vue') },
        { path: 'teacher/edit/:id', name: 'teacher-edit', component: () => import('./../views/main/Teacher/Edit.vue') },
        { path: 'class', name: 'class', component: () => import('./../views/main/Class/index.vue') },
        { path: 'class/add', name: 'class-add', component: () => import('./../views/main/Class/Add.vue') },
        { path: 'class/edit/:id', name: 'class-edit', component: () => import('./../views/main/Class/Edit.vue') },
        { path: 'headteacher', name: 'headteacher', component: () => import('./../views/main/HeadTeacher/index.vue') },
        { path: 'headteacher/add', name: 'headteacher-add', component: () => import('./../views/main/HeadTeacher/Add.vue') },
        { path: 'headteacher/edit/:id', name: 'headteacher-edit', component: () => import('./../views/main/HeadTeacher/Edit.vue') },
        { path: 'security', name: 'security', component: () => import('./../views/main/Security/index.vue') },
        { path: 'security/add', name: 'security-add', component: () => import('./../views/main/Security/Add.vue') },
        { path: 'security/edit/:id', name: 'security-edit', component: () => import('./../views/main/Security/Edit.vue') },
        { path: 'staff', name: 'staff', component: () => import('@/views/main/Staff/index.vue') },
        { path: 'staff/add', name: 'staff-add', component: () => import('@/views/main/Staff/Add.vue') },
        { path: 'staff/edit/:userId', name: 'staff-edit', component: () => import('@/views/main/Staff/Edit.vue') },
        { path: 'role-manage', name: 'role-manage', component: () => import('@/views/permission/RoleManage.vue') },
        {path: 'department', name: 'department', component: () => import('@/views/permission/DepartmentManage.vue'), meta: { title: '角色管理' }},
        { path: 'account', name: 'account', component: () => import('@/views/permission/AccountManage.vue'), meta: { title: '账号管理' } },
        { path: 'exam', name: 'exam', component: () => import('@/views/main/Exam/index.vue'), meta: { title: '考试管理' } },
        { path: 'exam/add', name: 'exam-add', component: () => import('@/views/main/Exam/Add.vue'), meta: { title: '创建考试' } },
        { path: 'exam/edit/:id', name: 'exam-edit', component: () => import('@/views/main/Exam/Edit.vue'), meta: { title: '编辑考试' } },
        { path: 'exam/detail/:id', name: 'exam-detail', component: () => import('@/views/main/Exam/Detail.vue'), meta: { title: '考试详情' } },
        { path: 'exam/monitor/:id', name: 'exam-monitor', component: () => import('@/views/main/Exam/Monitor.vue'), meta: { title: '考试监控' } },
        { path: 'exam/questions/:id', name: 'exam-questions', component: () => import('@/views/main/Exam/Questions.vue'), meta: { title: '考试题目设置' } },
        { path: 'grade', name: 'Grade', component: () => import('@/views/main/Grade/index.vue'), meta: { title: '成绩管理', icon: 'el-icon-data-analysis' } },
        { path: 'grade/detail', name: 'GradeDetail', component: () => import('@/views/main/Grade/detail.vue'), meta: { title: '成绩详情', hidden: true } },
        { path: 'grade/analysis', name: 'GradeAnalysis', component: () => import('@/views/main/Grade/analysis.vue'), meta: { title: '成绩分析', icon: 'el-icon-data-line' } },
        { path: 'exam/replay', name: 'Replay', component: () => import('@/views/main/Exam/Replay.vue'), meta: { title: '考试回放', icon: 'el-icon-data-line' } },
        { path: '', redirect: '/main/danger' },
        {
          path: 'attendance',
          name: 'attendance',
          redirect: '/main/attendance/manage',
          children: [
            { path: 'manage', name: 'attendance-manage', component: AttendanceManage },
            { path: 'absence', name: 'attendance-absence', component: AbsenceStatistics },
            { path: 'leave', name: 'attendance-leave', component: LeaveManage },
            { path: 'history', name: 'attendance-history', component: HistoryAttendance },
            { path: 'leaveSchool', name: 'attendance-leaveSchool', component: LeaveSchoolManage },
            { path: 'setting', name: 'attendance-setting', component: AttendanceSetting }
          ]
        },
        {
          path: 'teacher-attendance',
          name: 'teacher-attendance',
          redirect: '/main/teacher-attendance/manage',
          children: [
            { path: 'manage', name: 'teacher-attendance-manage', component: TeacherAttendanceManage },
            { path: 'approval', name: 'teacher-leave-approval', component: TeacherLeaveApproval },
            { path: 'statistics', name: 'teacher-attendance-stats', component: TeacherAttendanceStats },
            { path: 'time-setting', name: 'teacher-attendance-settings', component: TeacherAttendanceSettings },
          ]
        },
        {
        path: 'patrol',
        name: 'patrol',
        component: () => import('@/views/safety/Layout.vue'),
        redirect: '/main/patrol/category-level1',
        children: [
          {
            path: 'category-level1',
            name: 'PatrolCategoryLevel1',
            component: () => import('@/views/safety/CategoryLevel1.vue'),
            meta: { title: '巡查一级分类' }
          },
          {
            path: 'category-level2',
            name: 'PatrolCategoryLevel2',
            component: () => import('@/views/safety/CategoryLevel2.vue'),
            meta: { title: '巡查二级分类' }
          },
          {
            path: 'sign',
            name: 'PatrolSign',
            component: () => import('@/views/safety/PatrolSign.vue'),
            meta: { title: '签到点管理' }
          },
          {
            path: 'patrol-record-stats',
            name: 'PatrolRecordStats',
            component: () => import('@/views/safety/PatrolRecordStats.vue'),
            meta: { title: '安全巡查记录' }
          },
          {
            path: 'patrol-record-detail',
            name: 'PatrolRecordDetail',
            component: () => import('@/views/safety/PatrolRecordDetail.vue'),
            meta: { title: '巡查明细' }
          }
        ]
      },
      {
        path: 'guard',
        name: 'GuardManage',
        component: () => import('@/views/guard/GuardManage.vue'),
        redirect: '/main/guard/point',
        children: [
          {
            path: 'point',
            name: 'GuardPoint',
            component: () => import('@/views/guard/GuardPoint.vue'),
            meta: { title: '护导点' }
          },
          {
            path: 'schedule',
            name: 'GuardSchedule',
            component: () => import('@/views/guard/GuardSchedule.vue'),
            meta: { title: '护导排班' }
          }
        ]
      },
      ]
    }
  ],
})

export default router
